﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WisDom.IService;
using WisDom.Utils;

namespace WisDom.UnifiedPortal.Areas.Admin.Controllers
{
    /// <summary>
    /// 数据源 控制器
    /// </summary>
    [Area("admin")]
    public class DataSourceController : Controller
    {
        private IUPDataSourceInterface _idataSourceService;

        public DataSourceController(IUPDataSourceInterface idataSourceService)
        {
            _idataSourceService = idataSourceService;
        }
        /// <summary>
        /// 数据源 index首页
        /// </summary>
        /// <returns></returns>
        public async Task<IActionResult> Index()
        { 
            return View();
        }


        #region 查找数据
        /// <summary>
        /// 获取数据源的分页数据
        /// 访问地址:/admin/DataSource/GetPageDataList
        /// </summary>
        /// <returns></returns>
        public async Task<IActionResult> GetPageDataList([FromBody]Pagination pagination)
        { 
            var lst = await _idataSourceService.GetPageList(pagination, "");
            DataResult result = new DataResult();

            result.result = lst;
            result.count = pagination.Records;
            return Json(result);
        }
        #endregion
    }

    public class DataResult
    {
        public IEnumerable result { get; set; }
        public int count { get; set; }
    }
 
}